<?php
/**
 * Created by PhpStorm.
 * User: wenwb
 * Date: 2023/8/8
 * Time: 11:14
 */

namespace business\elasticsearch\services\dto;

class ScoreCondition
{
    public $isDeveloper;
    public $isSupplier;
    public $bidKeyword;
    public $supplierKeyword;
    public $subscriptProvinceCode;
    public $subscriptCityCode;
    public $currentCompanyName = '';
    public $currentOrganizingCode = '';
    public $phone_type;
    public $bidOwnerMobile;
    public $lastOneYear;

    public $keywordWeight;//关键词匹配加分
    public $areaWeight;//订阅区域匹配加分
    public $currentCompanyWeight;//联系人所在公司为打开的客户详情页企业的联系人，加分
    public $phoneTypeWeight;//联系方式加分
    public $lastOneYearWeight;//近一年更新，加分
    public $bidOwnerMobileWeight;//招标负责人，加分

    const DEVELOPER_CONTACT = 'developer_contact';
    const SUPPLIER_CONTACT = 'supplier_contact';
    const COOPERATION_CONTACT = 'cooperation_contact';

    public function __construct($scoreType = self::DEVELOPER_CONTACT)
    {
        $scoreConfig = [];
        if ($scoreType == self::DEVELOPER_CONTACT) {
            $scoreConfig = isset(\Yii::$app->params['DeveloperContactWeightConfig']) ? \Yii::$app->params['DeveloperContactWeightConfig'] : [];
        } elseif ($scoreType == self::SUPPLIER_CONTACT) {
            $scoreConfig = isset(\Yii::$app->params['SupplierContactWeightConfig']) ? \Yii::$app->params['SupplierContactWeightConfig'] : [];
        } elseif ($scoreType == self::COOPERATION_CONTACT) {
            $scoreConfig = isset(\Yii::$app->params['CooperationContactWeightConfig']) ? \Yii::$app->params['CooperationContactWeightConfig'] : [];
        } else {
            $scoreConfig = [];
        }
        //var_dump($scoreConfig);die;
        $this->keywordWeight = isset($scoreConfig['keywordWeight']) ? $scoreConfig['keywordWeight'] : 100;
        $this->areaWeight = isset($scoreConfig['areaWeight']) ? $scoreConfig['areaWeight'] : 50;
        $this->currentCompanyWeight = isset($scoreConfig['currentCompanyWeight']) ? $scoreConfig['currentCompanyWeight'] : 50;
        $this->phoneTypeWeight = isset($scoreConfig['phoneTypeWeight']) ? $scoreConfig['phoneTypeWeight'] : 50;
        $this->lastOneYearWeight = isset($scoreConfig['lastOneYearWeight']) ? $scoreConfig['lastOneYearWeight'] : 100;
        //bidOwnerMobileScore默认给一个比较大的分数，置顶第一
        $this->bidOwnerMobileWeight = isset($scoreConfig['bidOwnerMobileWeight']) ? $scoreConfig['bidOwnerMobileWeight'] : 500;

    }
}
